import { FormControl } from './FormControl.js';
import { FormGroup } from './FormGroup.js';
import { FormArray } from './FormArray.js';
// import { FormControlData } from './form.interface';


/**
 * 快速构建表单数据。
 */
export class FormBuilder {

	static control = (
		data = {}
	) => {
		return new FormControl(data);
	};
	/**
	 * @description 创建 FormGroup
	 * @param {[key: string]: any}  obj
	 * @example
		form = fb.group({
			name: fb.control('', []),
			password: fb.control('', ['required']),
			repassword: fb.control(''),
		});
	 */
	static group = (obj) => {
		return new FormGroup(obj);
	};
	/**
	 * @description 创建 FormArray
	 * @param {Array<any>}  arr
	 * @example
	 form = fb.array([
		 fb.control(''),
		 fb.group({
			 fb.control(''),
		 });
	 ]);
	 */
	static array = (arr) => {
		return new FormArray(arr);
	};
}
